<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
	<meta name="apple-mobile-web-app-capable" content="yes" />
	<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
	<meta name="format-detection" content="telephone=yes" />
	<meta name="msapplication-tap-highlight" content="no" />
    <title>Photo Wall</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            border: none;
            list-style: none;
        }

        html, body, ul{
            width: 100%;
            height: 100%;
        }

        #ps{
            width: 100%;
            height: 100%;

            position: relative;
        }

        #ps li{
            box-shadow: 0 0 30px #000;

            position: absolute;

            transition: all 1s;
        }

        #ps li.current{
            left: 50% !important;
            top: 50% !important;
            transform: rotate(0deg) translate(-50%, -50%) scale(1.2, 1.2) !important;
            z-index: 99;
        }
    </style>
</head>
<body>
   <ul id="ps"></ul>
<script src="js/Underscore-min.js"></script>
<script>
    window.onload = function () {
        var ps = document.getElementById("ps");

        //动态创建li标签
        for(var i=0; i<5; i++){
            //创建li标签
            var li = document.createElement("li");
            ps.appendChild(li);

            //创建img标签
            var img = document.createElement("img");
            img.src = "./images/pic" + (i + 1) + ".jpg";
            img.height = 300;
            li.appendChild(img);
        }

        //获取所有的li
        var allLis = ps.children;

        var screenW = document.documentElement.clientWidth - 500;
        var screenH = document.documentElement.clientHeight - 700;


        //遍历
        for(var j=0; j<allLis.length; j++){
            //取出单个li标签
            var li = allLis[j];

            //随机分布
            li.style.left = _.random(0, screenW) + 'px';
            li.style.top = _.random(0, screenH) + 'px';

            //随机角度
            li.style.transform = 'rotate(' + _.random(0, 360) +'deg)';

            //点击事件
            li.onclick = function () {
                for(var i = 0; i<allLis.length; i++){
                    allLis[i].className = '';
                }
                this.className = 'current';
            }
        }
    }
</script>
</body>
</html>